using System;
using System.IO;

namespace DynamicConfigurationManager.ConfigMapAttributes
{
    internal class WebServiceBinPath : IConfigMapAttribute
    {
        public bool Execute( string configMapAttribute )
        {
            var rtnValue = false;
            var assemblyPath = GetType().Assembly.CodeBase;

            assemblyPath = Path.GetDirectoryName( assemblyPath );
            assemblyPath = assemblyPath?.Replace( @"file:\", "" );

            if( assemblyPath != null && configMapAttribute.Length != 0 )
            {
                rtnValue = assemblyPath.Equals( configMapAttribute.TrimEnd( "\\".ToCharArray() ), StringComparison.InvariantCultureIgnoreCase );
            }

            return rtnValue;
        }
    }
}